import axios from "axios"
import { useUserStore } from "@/stores/user"


const httpInstance = axios.create({
    baseURL: 'http://8.137.150.98:7003',
    timeout: 5000
})

// 拦截器

// axios 请求拦截器
httpInstance.interceptors.request.use(config => {
    const token = useUserStore().Token;
    if (token) {
        config.headers.Authorization = `${token}`
    }
    return config
}, e => Promise.reject(e))

// axios 响应式拦截器
httpInstance.interceptors.response.use(res => res.data, e => {
    return Promise.reject(e)
})

export default httpInstance